<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
    <link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
    <link rel="stylesheet" href="../assets/agile/css/flat/flat.color.css">
    <link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
    <link rel="stylesheet" href="../assets/app/css/app.css" />
<body>

<div id="header" class="bar bar-nav">
<div class="titlebar">
<a href="#left_overlay_aside"><i class="iconfont iconline-menu"></i></a>
<h1>吉祥夺宝</h1>
<a class="icon icon-search pull-right index-icon-search" href="/?/mobile/mobile/search" style="font-size:24px;"></a>
</div>
</div>

<div style="width:100%;height:150px;margin-top:44px;">
	<div class="slider">
	</div>
</div>

<section style="margin-bottom:0px !important;margin-top:0px !important;">
<div class="menu_icon">
    <ul>
        <li><a href="?/mobile/home/qiandao"><img src="../res/icon_4.png" />签到</a></li>
        <li><a href="?/mobile/mobile/glist"><img src="../res/icon_2.png" />创业众筹</a></li>
        <li><a href="?/gt"><img src="../res/icon_7.png" />组团基地</a></li>
        <li><a href="?/mobile/agent"><img src="../res/icon_3.png" />合伙人</a></li>
        <li><a href="?/mobile/shaidan"><img src="../res/icon_5.png" />晒单</a></li>
        <li><a href="?/mobile/home/invite"><img src="../res/icon_6.png" />推广有奖</a></li>
        <li><a href="?/mobile/mobile/lottery"><img src="../res/icon_8.png" />最新揭晓</a></li>
        <li><a href="?/mobile/home/userrecharge"><img src="../res/icon_1.png" />充值</a></li>
    </ul>
</div>

<div class="container jx_goods autoLot">    
    <div class="news_jx">
        <span class="jx-span">即将揭晓</span>
        <button class="btn btn-link btn-nav pull-right">
            <a href="###"><span class="icon icon-right-nav"></span></a>
        </button>
    </div>
<div id="autoLottery">
		<div id="afterlist"></div>
		<div class="autotime" item="12" tag="end" data-endtime="120">
			<div class="autotime_left">
			<p><a href="javascript:;">加载中...</a></p>
			<div class="lot">
			<span class="count_time"></span>
			<div class="LotteryTime"><b class="minute">00</b>:<b class="second">00</b>:<b class="millisecond">00</b></div>
			<!-- 
			<p style="font-size:12px;" class="pz">恭喜<a href="?/mobile/mobile/userindex/<?php echo $value['q_uid'];?>" style="color:#3F5FD5;font-size:12px;"><?php echo get_user_name($value['q_uid']);?></a>获得</p>
			 -->
			</div>
			</div>
			<div class="autotime_right">
			<a href="javascript:;">
				<img alt="" class="lazy" data-original="" />
			</a>
			</div>
		</div>
		<div class="autotime" item="12" tag="end" data-endtime="120">
			<div class="autotime_left">
			<p><a href="javascript:;">加载中...</a></p>
			<div class="lot">
			
			<span class="count_time"></span>
			<div class="LotteryTime"><b class="minute">00</b>:<b class="second">00</b>:<b class="millisecond">00</b></div>
			<!-- 
			<p style="font-size:12px;" class="pz">恭喜<a href="?/mobile/mobile/userindex/<?php echo $value['q_uid'];?>" style="color:#3F5FD5;font-size:12px;"><?php echo get_user_name($value['q_uid']);?></a>获得</p>
			 -->
			</div>
			</div>
			<div class="autotime_right">
			<a href="javascript:;">
				<img alt="" class="lazy" data-original="" />
			</a>
			</div>
		</div>
		<div class="autotime" item="12" tag="end" data-endtime="120">
			<div class="autotime_left">
			<p><a href="javascript:;">加载中...</a></p>
			<div class="lot">
			
			<span class="count_time"></span>
			<div class="LotteryTime"><b class="minute">00</b>:<b class="second">00</b>:<b class="millisecond">00</b></div>
			<!-- 
			<p style="font-size:12px;" class="pz">恭喜<a href="?/mobile/mobile/userindex/<?php echo $value['q_uid'];?>" style="color:#3F5FD5;font-size:12px;"><?php echo get_user_name($value['q_uid']);?></a>获得</p>
			 -->
			</div>
			</div>
			<div class="autotime_right">
			<a href="javascript:;">
				<img alt="" class="lazy" data-original="" />
			</a>
			</div>
		</div>
		<div class="autotime" item="12" tag="end" data-endtime="120">
			<div class="autotime_left">
			<p><a href="javascript:;">加载中...</a></p>
			<div class="lot">
			
			<span class="count_time"></span>
			<div class="LotteryTime"><b class="minute">00</b>:<b class="second">00</b>:<b class="millisecond">00</b></div>
			<!-- 
			<p style="font-size:12px;" class="pz">恭喜<a href="?/mobile/mobile/userindex/<?php echo $value['q_uid'];?>" style="color:#3F5FD5;font-size:12px;"><?php echo get_user_name($value['q_uid']);?></a>获得</p>
			 -->
			</div>
			</div>
			<div class="autotime_right">
			<a href="javascript:;">
				<img alt="" class="lazy" data-original="" />
			</a>
			</div>
		</div>
	</div>
</div>

<div class="container jx_goods">    
    <div class="news_jx renqi_recommend">
        <span class="jx-span">人气推荐</span>
        <button class="btn btn-link btn-nav pull-right">
            <a href="###"><span class="icon icon-right-nav"></span></a>
        </button>
    </div>
</div>


<div id="footer">
  <nav class="bar bar-tab">
      <a class="tab-item" tapmode="hover" onclick="randomSwitchBtn('home');">
          <span class="icon iconline-home"></span>
          <span class="tab-label">首页</span>
      </a>
      <a class="tab-item" tapmode="hover" onclick="randomSwitchBtn('list');">
          <span class="icon iconline-grid"></span>
          <span class="tab-label">所有商品</span>
      </a>
      <a class="tab-item" tapmode="hover" onclick="randomSwitchBtn('lastnew');">
          <span class="icon iconline-bulb"></span>
          <span class="tab-label">最新揭晓</span>
      </a>
      <a class="tab-item head-shopcart" id="headShopcart" tapmode="hover" onclick="randomSwitchBtn('cart');">
          <span class="icon iconline-shop-basket"></span>
          <span class="tab-label">购物车</span>
          <em class="footer_goods_num" style="display: block;">2</em>
      </a>
      <a class="tab-item" tapmode="hover" onclick="randomSwitchBtn('user');">
          <span class="icon iconline-uid"></span>
          <span class="tab-label">我的</span>
      </a>
  </nav>
</div>
<div id="copyright"></div>
		
</section>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/jquery.lazyload.min.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
window.isHide = {
    adver : 0,
    renqi : 0,
    okshow : 0
};
$(function(){
//飞入购物车动画
var f_flag = true;
$('body').on('click','.oneget',function(){
	var _this = $(this);
	if(f_flag == false){
		return false;
	}
	f_flag = false;
	var goods_id = parseInt(_this.attr('goods_id'));
	$.ajax({
		type : 'POST',
		url : config.url+'/mobile/ajax/addShopCart/'+goods_id+'/'+1,
		beforeSend : function(){
			var img = _this.parents('figure').find('img');
			var flyElm = img.clone().css('opacity', 0.85);
			$('body').append(flyElm);
			flyElm.css({
				'z-index': 9000,
				'display': 'block',
				'position': 'absolute',
				'top': img.offset().top +'px',
				'left': img.offset().left +'px',
				'width': img.width() +'px',
				'height': img.height() +'px'
			});
			flyElm.stop().animate({
				top: $('.head-shopcart').offset().top,
				left: $('.head-shopcart').offset().left,
				width: 20,
				height: 20
			}, 'slow', function() {
				f_flag = true;
				flyElm.remove();
			});
		},
		success : function(res){
			var res = $.parseJSON(res);
			if (res['code'] == 0) {
				if(res['num'] > 0){
					$('nav.bar-tab .footer_goods_num').text(res['num']);
					$('nav.bar-tab .footer_goods_num').show();
				}
			}
		}
	});
    }); //飞入购物车结束
   
getCopyright();
function getCopyright(){
    $.ajax({
        type : 'GET',
        url : config.url+"/app.php?act=copyright",
        dataType : 'json',
        success : function(res){
            $('#copyright').html(res['html']);
        }
    });
}

renqi();

//人气商品
function renqi(){
  var rq = '';
  $.ajax({
      type : 'GET',
      url : config.url+"/app.php?act=renqi",
      dataType : 'json',
      success : function(info){
      if(info['status'] == 0){
          setTimeout(function(){
              renqi();
          },5000);
      }else{
          for(var j=0;j<info['data'].length;j++){
                var s="";
              if (j % 2 != 0){
                  s = 'style="border-right:none;"';
              }
              
      rq += '<figure '+s+'><div class="goods_img">';
      rq += '<a href="'+info['data'][j]['id']+'">';
      rq += '<img class="lazy" data-original="'+config.upload_url+'/'+info['data'][j]['thumb']+'"  alt=""></a></div>';
      rq += '<figcaption><p><a href="'+info['data'][j]['id']+'">'+info['data'][j]['title']+'</a></p>';
      rq += '<div class="info"><div class="left">';
      var baifebi = (info['data'][j]['canyurenshu']/info['data'][j]['zongrenshu'])*100;
      rq += '<progress max="100" value="'+baifebi+'" class="css3">';
      rq += '<div class="progress-bar"></div></progress>';
      rq += '<span class="bf_color">夺宝进度<em class="bf">'+parseInt(baifebi)+'%</em></span>';
      rq += '<div class="clear"></div>';
      rq += '<button class="common-btn mygroup"><a href="'+info['data'][j]['id']+'">立即夺宝</a></button>';
      rq += '<button class="common-btn oneget" flag="true" goods_id="'+info['data'][j]['id']+'"><a href="javascript:;">加入清单</a></button>';
      rq += '</div></div></figcaption></figure>';
     }
         window.isHide.renqi = 1;
         $('.renqi_recommend').after(rq);
         window.isHide.okshow = 1;
         lyzimg();
      }
     }
  });
}

//即将揭晓
function okshow(){
         $.ajax({
             type : 'GET',
             url:config.url+'/app.php?act=homeget',
             success : function(ret){
            if(ret['status'] == 1){
            var html = '';
	            for(var i=0; i<ret['data'].length;i++){
	                var style="";
	                if(i%2!=0){
	                    style = 'style="border-right:none;"';
	                }
	        		html += '<div class="autotime" '+style+' item="'+ret['data'][i]['id']+'" tag="end" data-endtime="120">';
	        		html += '<div class="autotime_left">';
	        		html += '<p><a href="javascript:;">'+ret['data'][i]['title']+'</a></p>';
					html += '<div class="lot">';
					html += '<p style="font-size:12px;" class="pz">恭喜<a href="javascript:;" style="color:#3F5FD5;font-size:12px;">'+ret['data'][i]['username']+'</a>获得</p>';
					html += '</div></div><div class="autotime_right">';
					html += '<a href="javascript:;">';
					html += '<img alt="" class="lazy" data-original="'+config.upload_url+'/'+ret['data'][i]['thumb']+'" />';
					html += '</a></div></div>';  
	            }
              	$('.autoLot .news_jx').after(html);
              	lyzimg();
              	window.isHide.renqi = 1;
            }else{
            	
            }  
          }
     });
}

okshow();

$.ajax({
    url: config.url+'/app.php?act=slides',
    dataType : 'json',
    type: 'POST',
    success : function( ret, err ){
        if(ret['state'] == 0){
            var img = '';
             for(var i=0; i < ret['listItems'].length; i++){
                img += '<li><img src="'+ret['listItems'][i]['src']+'"/></li>';
             }
             //$('#adver').html(img);
         	 window.isHide.adver = 1;
             var img = '';
             img += '<li><img src="'+config.url+'/uploads/banner/20160110/47035429411665.jpg"/></li>';
             img += '<li><img src="'+config.url+'/uploads/banner/20160110/53039571411650.jpg"/></li>';
             img += '<li><img src="'+config.url+'/uploads/banner/20160110/88685068411693.jpg"/></li>';
             //$('#adver').html(img);
        }else{
        	
        }
    }
});

});

apiready = function(){
        var header = $api.byId('header');
        //适配iOS 7+，Android 4.4+状态栏
		api.showProgress({
		     title : '加载中...',
		     text : ''
		 }); 
		var setIntID = setInterval(function(){
		    if(window.isHide.renqi == 1 && window.isHide.okshow == 1){
		        api.hideProgress();
		        clearInterval(setIntID);
		    }
		},500);
		
		var UIScrollPicture = api.require('UIScrollPicture');
		UIScrollPicture.open({
		    rect: {
		        x: 0,
		        y: 44,
		        w: api.winWidth,
		        h: 150
		    },
		    data: {
		        paths: [
		                ''+config.url+'/uploads/banner/20160110/47035429411665.jpg', 
		                ''+config.url+'/uploads/banner/20160110/53039571411650.jpg', 
		                ''+config.url+'/uploads/banner/20160110/88685068411693.jpg'
		                ],
		    },
		    styles: {
		        caption: {
		            height: 35,
		            color: '#E0FFFF',
		            size: 13,
		            bgColor: '#696969',
		            position: 'bottom'
		        },
		        indicator: {
		            align: 'center',
		            color: '#FFFFFF',
		            activeColor: '#DA70D6'
		        }
		    },
		    placeholderImg: 'widget://res/pic.jpg',
		    contentMode: 'scaleToFill',
		    interval: 3,
		    loop: true,
		    fixedOn: api.frameName,
		    fixed: false
		},function( ret, err ){
		    if( ret ){
		    	alert( JSON.stringify( ret ) );
		    }else{
		    	alert( JSON.stringify( err ) );
		    }
		});
		
};
</script>
</html>